package com.zy.yygh.hosp.controller;

import com.zy.yygh.common.result.Result;
import com.zy.yygh.hosp.service.HospitalService;
import com.zy.yygh.model.hosp.Hospital;
import com.zy.yygh.vo.hosp.HospitalQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/admin/hosp/hospital")
//@CrossOrigin
@Api(tags = "医院管理")
public class HospitalController {
    @Autowired
    private HospitalService hospitalService;


//    医院列表
    @GetMapping("list/{page}/{limit}")
    public Result listHosp(@PathVariable Integer page,
                           @PathVariable Integer limit,
                           HospitalQueryVo hospitalQueryVo){

       Page<Hospital> pageModel=hospitalService.selectHospPage(page,limit, hospitalQueryVo);

        return Result.ok(pageModel);
    }

//    更新医院的上线状态
    @ApiOperation(value = "更新医院的上线状态")
    @GetMapping("updateStatus/{id}/{status}")
    public Result updateHospStatus(@PathVariable("id") String id,
                                   @PathVariable("status") Integer status){
        hospitalService.updateStatus(id,status);
        return Result.ok();
    }
//    获取医院详情
    @ApiOperation(value = "获取医院详情")
    @GetMapping("showHospDetail/{id}")
    public Result showHospDetail(@PathVariable("id")  String id){
        Map<String,Object>hosp=hospitalService.getHospById(id);
        return Result.ok(hosp);
    }


}
